import { createApp } from "vue";
import { createPinia } from "pinia";
import "normalize.css";
import "@/assets/styles/common.less";
import piniaPersistedState from "pinia-plugin-persistedstate";
import type Message from "./components/library/Message";

import App from "./App.vue";
import router from "./router";
import plugins from "@/components/library/index";

const app = createApp(App);

const pinia = createPinia();
pinia.use(piniaPersistedState);

app.use(createPinia());
app.use(router);
app.use(pinia);
app.use(plugins);

// 判断当前是否是开发环境
if (process.env.NODE_ENV === "development") {
  // 动态导入 worker
  const worker = require("./mocks/browser").default;
  // 开启请求拦截成功
  worker.start({ onUnhandledRequest: "bypass", quiet: true });
}

declare module "vue" {
  interface ComponentCustomProperties {
    $message: typeof Message;
  }
}

app.mount("#app");
